import BuffUtil from '@/BuffUtil';
import Buff from '@/Buff';

import ItemUtil from '@/ItemUtil';
import RandomUtil from '@/RandomUtil';
export default class Item_点燃的蜡烛 {
    static id = 'C002';
    static 名称: string = '点燃的蜡烛';
    static 描述: string = '持续受到灼烧伤害';
    static 图标: string = 'assets\\icon\\Spell_Priest_VoidShift.blp';
    static buffId: string = 'buff_item_dianrandelazhu';
    static buffType: AppBuffType = {
        id: 'buff_item_dianrandelazhu',
        name: Item_点燃的蜡烛.名称,
        ubertip: Item_点燃的蜡烛.描述,
        art: Item_点燃的蜡烛.图标,
        attribute: {
            命中: -0.1,
        },
        interval: 1,
        onInterval: Item_点燃的蜡烛.buffInterval,
        dur: 5,
        targetArt: 'Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeDamageTarget.mdl',
        targetAttach: 'overhead',
    };
    static buffInterval(buff: Buff) {
        DamageSystemInstance.applyFireDamage(buff.getParent(), buff.getCaster(), 35, null, true);
    }
    constructor() {
        BuffUtil.registerBuffType(Item_点燃的蜡烛.buffType);
        EventManager.onTakeAttack(Item_点燃的蜡烛.spellEffect);
    }
    static spellEffect(d: DamageEventData) {
        if (!ItemUtil.isUnitHasItem(d.source, Item_点燃的蜡烛.id)) return;
        let r = RandomUtil.randomPercent();
        if (r > 0.25) return;
        BuffUtil.addBuff(d.target, Item_点燃的蜡烛.buffId, d.source);
    }
}
